<template>
	<view v-if="show" class="at-popup" :style="{
      top: top,
    }">
		<view class="user-list" v-for="(t, i) in canSelectList" :key="i">
			<view class="user-item" @click="selectUser(t)" :style="{
          'margin-bottom': i == 4 ? 0 : '',
          'border-bottom': i == 4 ? 'none' : ' 1rpx solid #0000000d',
        }">
				<view class="avatar" v-if="isPeopleAvatarExit(t.userVo.avatarCompress || t.showUserAvatar)">
					<image :src="t.userVo.avatarCompress || t.showUserAvatar" mode="aspectFill"></image>
				</view>
				<view class="avatar avator-font-setting" :style="{ background: `${t.defaultColor}`, fontSize: '30upx' }" v-else>
					{{ t.showUserName.slice(0, 1) }}</view>
				<view class="name">{{ t.showUserName }}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			groupMemberInfo: {
				type: Array,
				default: [],
			},
			// bottom: {
			//   type: String,
			//   default: "110rpx",
			// },
		},
		mounted() {},
		computed: {
			canSelectList() {
				const list = this.groupMemberInfo.filter(
					(o) => o.userId != this.$store.state.userId
				);
				if (list.length > 4) {
					this.top = '-540rpx'
				} else {
					this.top = (list.length * -110) + 'rpx'
				}
				return list
			},
		},
		data() {
			return {
				show: false,
				isMore: false,
				top: "-110rpx"
			};
		},
		methods: {
			selectUser(data) {
				this.$emit("confirm", [data]);
				this.show = false;
			},
			init() {
				uni.hideKeyboard();
				this.show = true;
			},
			close() {
				this.show = false;
			},
		},
	};
</script>

<style lang="scss" scoped>
	.at-popup {
		position: absolute;
		background: #f6f6f6;
		z-index: 12;
		max-height: 540rpx;
		overflow: auto;
	}

	.user-list {
		width: 100vw;
	}

	.content {
		padding-top: 85rpx;
	}

	.user-item {
		height: 108rpx;
		margin: 0rpx 30rpx;
		display: flex;
		align-items: center;

		.avatar {
			width: 60rpx;
			height: 60rpx;
			border-radius: 50%;
			display: flex;
			align-items: center;
			justify-content: center;
			color: white;

			image {
				width: 60rpx;
				height: 60rpx;
				border-radius: 50%;
			}
		}

		.name {
			font-size: 32rpx;
			font-family: Source Han Sans CN;
			font-weight: 600;
			color: #000000;
			margin-left: 31rpx;
		}
	}

	.popup-control {
		padding: 15rpx 30rpx;
		display: flex;
		justify-content: space-between;
		font-size: 30rpx;
		color: black;
		height: 85rpx;
		align-items: center;
		background: white;
		width: 100%;

		.title {
			font-weight: bold;
		}
	}

	.search-input {
		padding: 20rpx 30rpx;

		::v-deep.u-input {
			background-color: #f1f1f1;
		}
	}

	.success {
		padding: 10rpx 20rpx;
		border: 5rpx;
		min-width: 150rpx;

		text-align: center;
		background-color: #f1f1f1;
		color: #d5d5d6;
		letter-spacing: 1rpx;
	}

	.canClick {
		background: linear-gradient(0deg, #ff5551 0%, #ffa780 100%) !important;
		color: white;
	}

	::v-deep.u-index-bar {
		padding-bottom: 30rpx;
	}

	.all {
		background: linear-gradient(0deg, #ff5551 0%, #ffa780 100%) !important;
	}
</style>